#ITMD536 Software Testing and Maintenance.
#Final project <group assignment>
#Author: Wanglei ID:A20479012
cmake_minimum_required(VERSION 3.0)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_COMPILER "g++")
OPTION (USE_OpenMP "Use OpenMP" ON) 
if(USE_OpenMP) 
    message("OPENMP FOUND")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -std=c++11 -g -Wall -O2 -fPIC")
else()
    message("OPENMP NOT FOUND")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall -O2 -fPIC")
endif()

project(face)

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/source/face)
include_directories(${PROJECT_SOURCE_DIR}/source/main)
include_directories(${PROJECT_SOURCE_DIR}/source/dbase)

link_directories(${PROJECT_SOURCE_DIR}/libs)
#link_libraries(-Wl,--whole-archive TNN -Wl,--no-whole-archive)

file(GLOB FACE_SRC "${CMAKE_SOURCE_DIR}/source/face/*.cpp")
file(GLOB DB_SRC "${CMAKE_SOURCE_DIR}/source/dbase/*.cpp")
file(GLOB MAIN_SRC "${CMAKE_SOURCE_DIR}/source/main/*.cpp")

#libfaceitmd.so library build.
add_library(faceitmd SHARED ${FACE_SRC})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/libs)
set_target_properties(faceitmd PROPERTIES OUTPUT_NAME "faceitmd")
target_link_libraries(faceitmd opencv_core opencv_imgproc opencv_imgcodecs opencv_highgui opencv_video opencv_videoio ncnn)
target_link_libraries(faceitmd m dl pthread rt z)
#face execuate routinue build.
add_executable(face ${MAIN_SRC} ${DB_SRC})
target_link_libraries(face opencv_core opencv_imgproc opencv_imgcodecs opencv_highgui opencv_video opencv_videoio faceitmd)
target_link_libraries(face m dl -lgomp pthread rt z sqlite3)